﻿@namespace Bit.BlazorUI
@inherits BitInputBase<TValue>
@typeparam TItem
@typeparam TValue

<CascadingValue Value="this" IsFixed="true">
    <div style="display:none" hidden>@(Options ?? ChildContent)</div>
</CascadingValue>

<div @ref="RootElement" @attributes="HtmlAttributes"
     id="@_Id"
     role="radiogroup"
     style="@StyleBuilder.Value"
     class="@ClassBuilder.Value"
     dir="@Dir?.ToString().ToLower()"
     aria-label="@AriaLabel"
     aria-labelledby="@GetAriaLabelledBy()">

    <label id="@_labelId"
           disabled="@(IsEnabled is false)"
           style="@Styles?.LabelContainer"
           class="@Classes?.LabelContainer">
        @if (LabelTemplate is not null)
        {
            @LabelTemplate
        }
        else if (Label.HasValue())
        {
            <span style="@Styles?.Label" class="bit-chg-lbl @Classes?.Label">@Label</span>
        }
    </label>

    <div style="@Styles?.Container" class="bit-chg-cnt @Classes?.Container">
        @foreach (var item in _items)
        {
            <_BitChoiceGroupItem Item="item" ChoiceGroup="this" />
        }
    </div>

</div>